package com.mdxx.xczd.db.bo;

import android.content.ContentValues;
import android.content.Context;

import com.mdxx.xczd.bean.ImageBean;
import com.mdxx.xczd.bean.Point;
import com.mdxx.xczd.db.dao.LocationServerDAO;
import com.mdxx.xczd.db.dao.ServerDAO;

import java.util.List;

public class PhotoDataBO {

	private ServerDAO serverDAO;

	public PhotoDataBO(Context context){
		serverDAO = new LocationServerDAO(context);
	}

	/**
	 * 存图片数据
	 */
	public boolean insertLocationData(ImageBean photo) {
		boolean flag = false;		
		Point clola = photo.getClola();
		ContentValues values = new ContentValues();
		values.put("photo", photo.getPath());
		values.put("ptime", photo.getDate());
		values.put("lo", clola.getLongitude());
		values.put("la", clola.getLatitude());
		flag = serverDAO.add("location", values);
		return flag;
	}

	/**
	 * 查图片数据
	 */
	public List<ImageBean> queryLocationData() {
		String sql = "select * from location";
		List<ImageBean> list = serverDAO.queryMulti(sql);
		return list;
	}

	/**
	 * 删图片数据
	 */
	public void delLocationData() {
		String sql = "delete from location";
		serverDAO.delete(sql);
	}	
}
